package com.bajiao.admin.controller.index;

import com.bajiao.admin.base.AdminBaseController;
import com.bajiao.common.api.vo.Result;
import com.bajiao.service.statistics.StatisticsService;
import com.bajiao.vo.statistics.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 后台首页数据统计
 * @Author: FanJq
 * @Date: 2024-10-10
 * @Version: V1.0
 */
@Slf4j
@Api(tags = "后台首页数据统计")
@RestController
@RequestMapping("/index/statistics")
public class StatisticsController extends AdminBaseController<StatisticsOne, StatisticsService> {

    @Resource
    private StatisticsService statisticsService;

    @ApiOperation(value="首页统计")
    @GetMapping(value = "/one")
    public Result<?> getStatisticsOne() {
        StatisticsOne statisticsOne = statisticsService.getStatisticsOne();
        return Result.ok(statisticsOne);
    }

    @ApiOperation(value="曲线图")
    @GetMapping(value = "/two")
    public Result<?> getStatisticsTwo() {
        List<StatisticsTwo> resultList = statisticsService.getStatisticsTwo();
        return Result.ok(resultList);
    }

    @ApiOperation(value="累计核销量及面额统计")
    @GetMapping(value = "/three")
    public Result<?> getStatisticsThree() {
        startPage();
        List<StatisticsThree> resultList = statisticsService.getStatisticsThree();
        return Result.ok(getDataTable(resultList));
    }

    @ApiOperation(value="下单转化率统计")
    @GetMapping(value = "/four")
    public Result<?> getStatisticsFour(@RequestParam(required = false, defaultValue = "1") Integer type) {
        StatisticsFour response = statisticsService.getStatisticsFour(type);
        return Result.ok(response);
    }

    @ApiOperation(value="券类型销量占比")
    @GetMapping(value = "/five")
    public Result<?> getStatisticsFive(@RequestParam(required = false, defaultValue = "1") Integer type) {
        StatisticsFive response = statisticsService.getStatisticsFive(type);
        return Result.ok(response);
    }
}
